#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>

#define SQUARE(x) (x)*(x)
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))

int inc(const void*a, const void*b) {
	return *(char*) (a) - *(char*) b;
}
int main() {
	int n;
	char s[4];
	scanf("%d", &n);
	while (n--) {

		scanf("%s", s);
		qsort(s, 3, sizeof(s[0]), inc);
		printf("%c %c %c\n", s[0], s[1], s[2]);
	}
	return 0;
}
